<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        (function () {
            var oldcon = console.log
            window.console.log = function (res) {
                oldcon(res)
                document.body.innerHTML += res + '</br>'
            }
            // 封装数据
            var myObject = (function () {
                var _name = 'sven' // 私有变量
                return { getName: function () { return _name } }
            })()

            console.log(myObject.getName()) // 'sven'
            console.log(myObject._name) // undefined

            // 封装类型

            // 封装变化

            // 使用克隆的原型模式
            var Plane = function () {
                this.blood = 100;
                this, attackLevel = 1;
                this.defenseLevel = 1;
            }
            var plane = new Plane();
            plane.blood = 500;
            plane.attackLevel = 10;
            plane.defenseLevel = 7;

            var clonePlane = Object.create(plane)
            console.log(clonePlane.blood)
            console.log(clonePlane.attackLevel)
            console.log(clonePlane.defenseLevel)
            Object.create = Object.create || function (obj) {
                var F = function () { };
                F.prototype = obj;
                return new F();
            }

            // 克隆是创建对象的手段

            // 体验lo语言

            // 原型变成规范的一些规则

            // Javascript 中的原型继承
            var obj1 = new Object();
            var obj2 = {}
            console.log(Object.getPrototypeOf(obj1) === Object.prototype) // true
            console.log(Object.getPrototypeOf(obj2) === Object.prototype) // true

            // javascript 中没有类的概念创建出来的都是函数构造器
            
        })()
    </script>
</body>

</html>